package com.wang.controller;

import com.wang.service.TagService;
import com.wang.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tags")
public class TagController {

    @Autowired
    private TagService tagService;

//    最热标签
    @GetMapping("/hots")
    public Result hotsTag() {
        int limit = 6;
        Result result = tagService.findHotsTagId(limit);
        return result;
    }

//    文章所有标签
    @GetMapping()
    public Result allTags() {
        Result result = tagService.findAll();
        return result;
    }
    //文章列表-
    @GetMapping("/article/{index}/{num}/{tagId}")
    public Result articlesByTagId(@PathVariable("index") int index, @PathVariable("num") int num, @PathVariable("tagId") Long tagId) {
        Result result = tagService.listArticleByTagIdPage(index, num, tagId);
        return result;
    }
}
